package Observer_Strategy;

import java.util.ArrayList;
import java.util.List;

/**
 * 股票市场(被观察者)
 */
public class StockMarket {
    private List<Observer> observers = new ArrayList<>();

    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    public void removeObserver(Observer observer) {
        observers.remove(observer);
    }

    public void notifyObservers(double price) {
        for (Observer observer : observers) {
            observer.update(price);
        }
    }

}
